home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Frameworks / TransSkel 3.18 / Demos / C Demos / Button / Main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-04  |  3.1 KB  |  138 lines  |  [TEXT/KAHL]

  1. /*
  2.  * Button - Demonstration of TransSkel button outlining for document windows,
  3.  * modeless dialogs, movable modal dialogs, and modal dialogs.  Accompanies
  4.  * discussion in TransSkel Programmer's Note 10.
  5.  *
  6.  * Also demonstrates key-to-button mapping for document windows, modeless
  7.  * dialogs, movable modal dialogs, and modal dialogs.
  8.  *
  9.  * Modal Dialog 1 demonstrates how to install an outliner for the button that's
  10.  * indicated as the default in the dialog template, and how to make the
  11.  * outline change state when the button does.
  12.  *
  13.  * Modal Dialog 2 demonstrates how to install an outliner when the button to
  14.  * be outlined isn't necessarily the default, and how to change the button
  15.  * with which the outline is associated.
  16.  *
  17.  * The document window demonstrates simple use of SkelDrawButtonOutline()
  18.  * in a document window.
  19.  *
  20.  * 11 Jan 94 Paul DuBois
  21.  *
  22.  * 11 Jan 94 Release 1.00
  23.  * 21 Feb 94
  24.  * - Updated for TransSkel 3.11.
  25.  * 22 Apr 94
  26.  * - Tracks cursor in dialogs so it becomes an I-beam in edit text items.
  27.  * 25 Apr 94
  28.  * - Escape and command-period in document window cause Cancel button to flash.
  29.  * 27 Apr 94 Release 1.01
  30.  * - Added modeless dialog.  It acts just like the document window, but is
  31.  * implemented differently.
  32.  * 28 Apr 94
  33.  * - Document window was wrong type (it had a grow region but shouldn't).
  34.  * Fixed.
  35.  * 30 Apr 94
  36.  * - Added movable modal dialog (not available unless running at least System 7).
  37.  * 01 May 94
  38.  * - Adjust menus when movable modal dialog is in front so a modal dialog can't
  39.  * be selected.
  40.  * 18 Aug 94
  41.  * - Updated for TransSkel 3.18 (Support for Universal headers, PowerPC,
  42.  * Metrowerks).
  43.  */
  44.  
  45. # include    "TransSkel.h"
  46.  
  47. # include    "Button.h"
  48.  
  49.  
  50. /*
  51.  * Handle selection of "About Button..." item from Apple menu
  52.  */
  53.  
  54. static pascal void
  55. DoAppleMenu (short item)
  56. {
  57.     (void) SkelAlert (aboutAlrtRes, SkelDlogFilter (nil, true),
  58.                                             skelPositionOnParentDevice);
  59.     SkelRmveDlogFilter ();
  60. }
  61. /*
  62.  * Process selection from File menu.
  63.  */
  64.  
  65. static pascal void
  66. DoFileMenu (short item)
  67. {
  68.     switch (item)
  69.     {
  70.     case doModal1:
  71.         DoModal1 ();
  72.         break;
  73.     case doModal2:
  74.         DoModal2 ();
  75.         break;
  76.     case doModal3:
  77.         DoModal3 ();
  78.         break;
  79.     case doMovable:
  80.         DoMovableModal ();
  81.         break;
  82.     case quitApp:
  83.         SkelStopEventLoop ();
  84.         break;
  85.     }
  86. }
  87.  
  88.  
  89. void
  90. AdjustMenus (void)
  91. {
  92. MenuHandle    m;
  93.  
  94.     m = GetMHandle (skelAppleMenuID);
  95.     if (SkelIsMMDlog (FrontWindow ()))    /* disable "About..." item */
  96.         DisableItem (m, 1);
  97.     else
  98.         EnableItem (m, 1);
  99.     m = GetMHandle (fileMenuRes);
  100.     if (SkelIsMMDlog (FrontWindow ()))
  101.     {
  102.         DisableItem (m, doModal1);
  103.         DisableItem (m, doModal2);
  104.         DisableItem (m, doModal3);
  105.         DisableItem (m, doMovable);
  106.     }
  107.     else
  108.     {
  109.         EnableItem (m, doModal1);
  110.         EnableItem (m, doModal2);
  111.         EnableItem (m, doModal3);
  112.         EnableItem (m, doMovable);
  113.     }
  114. }
  115.  
  116.  
  117. int
  118. main (void)
  119. {
  120. MenuHandle    m;
  121. long    result;
  122.  
  123.     SkelInit ((SkelInitParamsPtr) nil);    /* initialize */
  124.  
  125.     SkelApple ("\pAbout Button\311", DoAppleMenu);
  126.     m = GetMenu (fileMenuRes);
  127.     (void) SkelMenu (m, DoFileMenu, nil, false, true);
  128.     if (SkelQuery (skelQSysVersion) < 0x00000700)
  129.         DisableItem (m, doMovable);
  130.  
  131.     SetupDocument ();
  132.     SetupModeless ();
  133.  
  134.     SkelEventLoop ();
  135.  
  136.     SkelCleanup ();                        /* clean up */
  137. }
  138.